package com.example.imageloader.common;

public class ImageOptions {

    //占位图
    public int placeImage;

    //错误图
    public int errorImage;

    //静态图片第一桢
    public boolean isStaticImg;

    //Gif 动图
    public boolean isGif;

    //图片大小
    public int[] imageSize;

    public boolean isRound;

    //是否开启内存缓存
    public boolean skipMemoryCache;

    //是否开启磁盘缓存
    public boolean skipDiskCache;

    public ImageOptions(
            int _placeImage,
            int _errorImage,
            boolean _isStaticImg,
            boolean _isGif,
            int[] _imageSize,
            boolean _isRound,
            boolean _skipMemoryCache,
            boolean _skipDiskCache
    ){
        this.placeImage = _placeImage;
        this.errorImage = _errorImage;
        this.isStaticImg = _isStaticImg;
        this.isGif = _isGif;
        if (this.isStaticImg && this.isGif){
            throw new IllegalStateException("[isStaticImg] [isGif] not at the same time set up is True");
        }
        this.imageSize = _imageSize;
        this.isRound = _isRound;
        this.skipMemoryCache = _skipMemoryCache;
        this.skipDiskCache = _skipDiskCache;
    }

    public int getPlaceImage() {
        return placeImage;
    }

    public int getErrorImage() {
        return errorImage;
    }

    public boolean isStaticImg() {
        return isStaticImg;
    }

    public boolean isGif() {
        return isGif;
    }

    public int[] getImageSize() {
        return imageSize;
    }

    public boolean isRound(){
        return isRound;
    }

    public boolean isSkipMemoryCache() {
        return skipMemoryCache;
    }

    public boolean isSkipDiskCache() {
        return skipDiskCache;
    }

    public static class Builder{

        private int placeImage;

        private int errorImage;

        private boolean isStaticImg;

        private boolean isGif;

        private int[] imageSize;

        private boolean isRound = false;

        private boolean skipMemoryCache = true;

        private boolean skipDiskCache = true;

        public Builder setPlaceImage(int placeImage){
            this.placeImage = placeImage;
            return this;
        }

        public Builder setErrorImage(int errorImage){
            this.errorImage = errorImage;
            return this;
        }

        public Builder setIsStaticImg(boolean isStaticImg){
            this.isStaticImg = isStaticImg;
            return this;
        }

        public Builder setIsGif(boolean isGif){
            this.isGif = isGif;
            return this;
        }

        public Builder setImageSize(int[] imageSize){
            this.imageSize = imageSize;
            return this;
        }

        public Builder setIsRound(boolean isRound){
            this.isRound = isRound;
            return this;
        }

        public Builder setSkipMemoryCache(boolean skipMemoryCache){
            this.skipMemoryCache = skipMemoryCache;
            return this;
        }

        public Builder setSkipDiskCache(boolean skipDiskCache){
            this.skipDiskCache = skipDiskCache;
            return this;
        }

        public ImageOptions build(){
            return new ImageOptions(placeImage,errorImage,isStaticImg,isGif,imageSize,isRound,skipMemoryCache,skipDiskCache);
        }

    }


}
